/*
 * Copyright (C) 2007-2012 Geometer Plus <contact@geometerplus.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

package org.geometerplus.zlibrary.text.model;

import org.geometerplus.zlibrary.text.view.CursorManager;

import java.util.List;

/**
 * 应该是文本绘制的控制设置
 */
public interface ZLTextModel {

    String getId();

    /**
     * 得到语言
     *
     * @return
     */
    String getLanguage();

    /**
     * 得到段落数量
     *
     * @return
     */
    int getParagraphsNumber();

    /**
     * 根据位置得到段落文件
     *
     * @param index
     * @return
     */
    ZLTextParagraph getParagraph(int index);

    /**
     * 删除所有标记
     */
    void removeAllMarks();

    /**
     * 得到第一个标记
     *
     * @return
     */
    ZLTextMark getFirstMark();

    /**
     * 得到最后一个标记
     *
     * @return
     */
    ZLTextMark getLastMark();

    /**
     * 得到下一个标记
     *
     * @param position
     * @return
     */
    ZLTextMark getNextMark(ZLTextMark position);

    /**
     * 得到上一个标记
     *
     * @param position
     * @return
     */
    ZLTextMark getPreviousMark(ZLTextMark position);

    /**
     * 得到所有标记
     *
     * @return
     */
    List<ZLTextMark> getMarks();

    /**
     * 根据位置得到文件长度
     *
     * @param index
     * @return
     */
    int getTextLength(int index);

    /**
     * 按照文本长度查找段落
     *
     * @param length
     * @return
     */
    int findParagraphByTextLength(int length);

    /**
     * 搜索
     *
     * @param text
     * @param startIndex
     * @param endIndex
     * @param ignoreCase
     * @return
     */
    int search(final String text, int startIndex, int endIndex, boolean ignoreCase);

    /**
     * 是否装载
     *
     * @return
     */
    boolean isLoaded();

    /**
     * 得到光标管理
     *
     * @return
     */
    CursorManager getCursorManager();

    /**
     * 销毁
     */
    void destroy();
}
